package com.hua.springCloud.controller;

import com.hua.springCloud.servicer.PaymentService;
import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
//@DefaultProperties(defaultFallback = "globle")
public class ControllerTest {
    @Autowired
    private PaymentService paymentService;

    @GetMapping("/consumer/getInfo/test")
//    @HystrixCommand
    public String getInfoTest(){
        return paymentService.getInfoTest();
    }

    @GetMapping("/consumer/getInfoTimeOut/test")
//    @HystrixCommand
    public String getInfoTimeOut(){
        return paymentService.getInfoTest();
    }

    //防止臃肿，
    public String globle(){
        return "您访问的服务器正在维修~~，请稍后再试~~·";
    }
    @RequestMapping("/consumer/paymentTest/{id}")
    public String getPayCount(@PathVariable("id")int id){
        return paymentService.getPayCount(id);
    }
}
